Set camera projection matrix based on lens params for other types of cameras #432
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🦟 Bug fix
Related issues: gazebosim/gz-rendering#968, #363
Related PR: gazebosim/gz-rendering#1002
Summary
For camera types other than
camera
, e.g.depth_camera
, the input camera sdf's lens<intrinsics>
or<projection>
parameters were not used. This PR refactor's the base CameraSensor class' logic for parsing and setting custom projection matrix in to a new function namedUpdateLensIntrinsicsAndProjection()
. The derived camera classes now call this function for setting a custom projection matrix if needed.Added tests to verify the intrinsic params published through the camera info topic for depth camera sensors.
Here is a test camera_projection.sdf world file. Together with gazebosim/gz-rendering#1002, a depth camera should now produce the same image / FOV as a regular camera when intrinsics or projection param are specified in the sdf.
Before: Cameras have different FOV.
![depth_camera_projection_before](https://private-user-images.githubusercontent.com/4000684/330306265-005890f5-9552-462e-b6d8-153534d91e65.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODc4NzgsIm5iZiI6MTczOTE4NzU3OCwicGF0aCI6Ii80MDAwNjg0LzMzMDMwNjI2NS0wMDU4OTBmNS05NTUyLTQ2MmUtYjZkOC0xNTM1MzRkOTFlNjUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMTEzOTM4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTliODMzMDg0ZWY5MDJmYTE1MWZmMTY2MDIxMGQ0YjYyNDZkZmNkMTg2N2JhZmYyNmNjMjc0OGRhOTA1Zjc2NCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.mQG9UQSJR9rCLCq8rGCpKVV70-FkwH6RZ3R-JFhWmGo)
After: Depth camera has the same horizontal FOV as a regular camera
![depth_camera_projection_after](https://private-user-images.githubusercontent.com/4000684/330306270-b6052c3a-856b-4554-9147-ba0df8d4875e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODc4NzgsIm5iZiI6MTczOTE4NzU3OCwicGF0aCI6Ii80MDAwNjg0LzMzMDMwNjI3MC1iNjA1MmMzYS04NTZiLTQ1NTQtOTE0Ny1iYTBkZjhkNDg3NWUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMTEzOTM4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Y2Q3NDMyODExMmEyMjYwYzRiOWNjNDY0MWQ4MzBjNmU2ZTgwYTU3Y2E0ZTQ5ZDVkNzA2MDdjYTRiNTYwZDVjNCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.4txApJvJt2a63lWoRx5ic2Yn9HPwGkwpWtJSl6Gm1JU)
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.